import * as util from '../../utils/util';
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    placeholder: {
      type: String,
      value: ''
    },
    bottomShow: {
      type: String,
      value: '',
      observer: function (bottomShow) {
        if (bottomShow) {
          this.setData({
            bottomShow: bottomShow
          })
        }
      }
    }

  },


  /**
   * 组件的初始数据
   */
  data: {
    bottomShow: "home",
    showPlace: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    closePlace: function (e) {
      util.preventMoreClick(this, () => {
        this.setData({
          showPlace: false
        })
      })
    },
    showSharePlace: function () {
      util.preventMoreClick(this, () => {
        this.setData({
          showPlace: !this.data.showPlace
        })
      })
    },
    goto: function (e) {
      let url = e.currentTarget.dataset.url;
      if (!url) {
        util.toast('体验环境不可用');
      } else {
        util.preventMoreClick(this, () => {
          this.setData({
            showPlace: false
          })
          wx.navigateTo({
            url: url,
          })
        })
      }
    },
    changeHomePage: function () {
      util.preventMoreClick(this, () => {
        this.setData({
          showPlace: false,
          bottomShow: 'home'
        })
        this.triggerEvent('showHomePage');
      })
    },
    changeUserPage: function () {
      util.preventMoreClick(this, () => {
        this.setData({
          showPlace: false,
          bottomShow: 'userInfo'
        })
        this.triggerEvent('showMyPage');
      })
    }
  }
})